package com.daxue.eurekaclientuserservice.jarload.adaptor.model;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.StringUtils;

/**
 * @author daxue0929
 * @date 2023/2/8
 */

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class AdaptorResourceModel {

    private String id;
    private String name;
    private AdaptorType adaptorType;
    private AdaptorResourceConfig resourceConfig;
    private Long createdOn;
    private Long modifiedOn;

    @JsonIgnore
    public String getVersion() {
        return DigestUtils.md5Hex(StringUtils.joinWith("-", modifiedOn, resourceConfig));
    }

}